export default class PhysicsManager {
    static openPhysicsSystem() {
        cc.director.getPhysicsManager().enabled = true
    }

    static closePhysicsSystem() {
        cc.director.getPhysicsManager().enabled = false
    }

    /**
     * 将一个节点的刚体设为静态
     * @param node 
     */
    static setRigidBodyStatic(node: cc.Node) {
        const rigidBodyComp = node.getComponent(cc.RigidBody)
        rigidBodyComp.type = cc.RigidBodyType.Static
    }

    /**
     * 将一个节点的刚体设为静态
     * @param node 
     */
    static setRigidBodyDynamic(node: cc.Node) {
        const rigidBodyComp = node.getComponent(cc.RigidBody)
        rigidBodyComp.type = cc.RigidBodyType.Dynamic
    }

    /**
     * 设置刚体的线性速度
     * @param node 
     */
    static setRigidBodyLinearVelocity(node: cc.Node, v: cc.Vec2) {
        const rigidBodyComp = node.getComponent(cc.RigidBody)
        rigidBodyComp.linearVelocity = v
    }
}
